﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using COM.OA.Entity;
using System.Collections.Generic;
using COM.OA.BLL;

public partial class qs_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        

    }
    protected void btChongZhi_Click(object sender, EventArgs e)
    {
       
        this.txtZhiWu.Text = "";
        this.txtShouji.Text = "";
        this.txtXiaolingtong.Text = "";
        this.txtBangong.Text = "";
        this.txtFenji.Text = "";
        this.txtEmail.Text = "";
        this.txtQQ.Text = "";
        this.txtChuanZhen.Text = "";
        this.txtMsn.Text = "";
        this.txtAdd.Text = "";
        this.txtBeiZhu.Text = "";



    }
    protected void btTiJiao_Click(object sender, EventArgs e)
    {
        if (Page.IsValid) 
        {
            //取姓名ID
            int uid =Int32.Parse( this.ddlUname.Text);
         
            users us = usersBLL.Select(uid);
            int bumenid = us.u_dept_id;
            //取部门ID
            int bid =Int32.Parse( this.ddlBumen.Text);

           
            
            if (!bumenid.Equals(bid))
            {
          this.Response.Write(string.Format(GetRedirect.WINALERT, "此人不是本部门人员请重新选择"));
          this.Response.Write(string.Format(GetRedirect.REDIRECT, "tijiaobangongtongxunlu.aspx"));    
            }
            else { 
        string zhiwu = this.txtZhiWu.Text;
        string shouji = this.txtShouji.Text;
        string xiaolingtong = this.txtXiaolingtong.Text;
        string bangong = this.txtBangong.Text;
        string fenji = this.txtFenji.Text;
        string email = this.txtEmail.Text;
        string qq = this.txtQQ.Text;
        string chuanzhen = this.txtChuanZhen.Text;
        string msn = this.txtMsn.Text;
        string add = this.txtAdd.Text;
        //取备注
        string beizhu = this.txtBeiZhu.Text;
        
        //string where = "dept_department='{0}'";
        //where = string.Format(where, bumen);
        //IList<department> listbumen = departmentBLL.Select(where);
        //department dt = listbumen[0];
        //int bumenId = dt.dept_id;
       
        //string where1 = "u_username='{0}'";
        //where1 = string.Format(where1, uname);
        //IList<users> listuname = usersBLL.Select(where1);
        //users user = listuname[0];
        //int userId = user.u_id;
        //封装
        addresslist al = new addresslist();
        al.al_u_id = uid;
        al.al_dept_id = bid;
        al.al_duty = zhiwu;
        al.al_mobile = shouji;
        al.al_smallclever = xiaolingtong;
        al.al_worktelephone = bangong;
        al.al_extension = fenji;
        al.al_fax = chuanzhen;
        al.al_email = email;
        al.al_qq = qq;
        al.al_msn = msn;
        al.al_address = add;


        //调用方法

        addresslistBLL.Insert(al);
        //跳到查询页
            this.Response.Write(string.Format(GetRedirect.WINALERT, "插入成功"));
            this.Response.Write(string.Format(GetRedirect.REDIRECT, "danweitxl.aspx"));



        }


        }
       

        
    }
   
}
